//
//  BaseNavigationController.swift
//  swiftDemo
//
//  Created by 众力金融 on 2018/8/28.
//  Copyright © 2018年 众力金融. All rights reserved.
//

import UIKit

class BaseNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // 设置导航栏标题
        let navBar = UINavigationBar.appearance()
        navBar.barTintColor = UIColor.QXRed;
        navBar.tintColor = UIColor.white
        var textAttributes: [NSAttributedStringKey: AnyObject] = [:]
        textAttributes[.foregroundColor] = UIColor.white
        textAttributes[.font] = UIFont.systemFont(ofSize: 20)
        navBar.titleTextAttributes = textAttributes
        
    }
    
}

extension BaseNavigationController {
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if viewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true;
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "checkUserType_backward_9x15_"), style: .plain, target: self, action: #selector(navigationBackClick))
        }
        super.pushViewController(viewController, animated: true)
    }
    @objc private func navigationBackClick() {
        popViewController(animated: true)
    }
}
